<?php

/**
 * @author Allan Dudar de Oliveira <allan@noiatec.com.br>
 */
class nt_site_twitter extends CI_Model {
    
    private $validation = array(
        array('field' => 'ID_TWEET', 'label' => 'Id Tweet', 'rules' => 'required|integer'),
        array('field' => 'TWEET', 'label' => 'Tweet', 'rules' => 'required'),
        array('field' => 'DATA', 'label' => 'Data do Tweet', 'rules' => ''),
        array('field' => 'STATUS', 'label' => 'Ativo', 'rules' => 'required'),
    );
    
    /**
     * Devolve o array com as validações para esta model
     * 
     * @return array com as regras de validação desta model
     */
    public function getRules(){
        return $this->validation;
    }  
    
    public function gravar($in){
        $this->db->insert('nt_site_twitter',$in);
    }

    public function getLastTweet(){
        return $this->db->order_by('DATA','DESC')->limit(1)->get('nt_site_twitter')->result_array();
    }

    public function getTweets($count=1){
        return $this->db->order_by('DATA','DESC')->where('STATUS',1)->limit($count)->get('nt_site_twitter')->result_array();
    }
    
}

